package com.ruoyi.web.controller.oper;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.oper.domain.OperChima;
import com.ruoyi.oper.domain.OperProduct;
import com.ruoyi.oper.domain.OperProitems;
import com.ruoyi.oper.domain.OperYanse;
import com.ruoyi.oper.service.IOperProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/oper/product")
public class OperProductController extends BaseController {

    @Autowired
    private IOperProductService operProductService;

    @GetMapping("/list")
    public TableDataInfo list(OperProduct operProduct){
        startPage();
        List<OperProduct> list = operProductService.selectProductList(operProduct);
        return getDataTable(list);
    }

    @GetMapping("/detail")
    public OperProduct detail(Integer productId){
        OperProduct operProduct = operProductService.selectProductById(productId);
        List<OperYanse> operYanseList = operProductService.getYanseList(productId);
        operProduct.setOperYanseList(operYanseList);
        return operProduct;
    }

    @GetMapping("/chimaDetail")
    public List<OperChima> chimaDetail(OperProitems operProitems){
        List<OperChima> chimaList = operProductService.getChimaList(operProitems);
        return chimaList;
    }
}
